package com.gk.study.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

    @Value("${File.uploadPath}")
    private String uploadPath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//
//        // 1. 映射 /myresources/** 到类路径下的 /myresources/ 目录
//        registry.addResourceHandler("/myresources/**")
//                .addResourceLocations("classpath:/myresources/");
//
//        // 2. 映射 /externalresources/** 到外部文件系统的指定目录
//        //    注意：需要替换成实际的外部文件系统路径
//        registry.addResourceHandler("/externalresources/**")
//                .addResourceLocations("file:/path/to/external/resources/");

        // 3. 映射 /custompath/** 到外部文件系统的另一个指定目录
        //    注意：需要替换成实际的外部文件系统路径
//        registry.addResourceHandler("/api/staticfiles/image/**")
//                .addResourceLocations("file:" + uploadPath);
    }
}